﻿using System;
using System.Drawing;
using DevExpress.XtraReports.UI;
using System.Data;
using System.Collections.Generic;
using UniMana.Utils.Helper;
using UniMana.Utils.Data;
using UniMana.Data;

namespace UniMana.Win.Training
{
    public partial class RprScore_TranscriptsTC : DevExpress.XtraReports.UI.XtraReport
    {
        private DBMain m_Score = new DBMain();
        private int m_iSubjectClassKey = 0;
        private List<int> m_lScoreType = new List<int>();
        private ClsReadNumber m_readnumber = new ClsReadNumber();
        public RprScore_TranscriptsTC(int subjectClassKey, List<int> scoreTypeList)
        {
            InitializeComponent();
            m_iSubjectClassKey = subjectClassKey;
            m_lScoreType = scoreTypeList;
            #region [Thong tin chung]
            Training_Subject_ClassInfo infoSubjectClass = new Training_Subject_ClassInfo(m_iSubjectClassKey);
            Training_SubjectInfo infoSubject = new Training_SubjectInfo(infoSubjectClass.Properties.Training_SubjectKey.ToInt());
            xrlSubject.Text = "Môn học: " + infoSubject.Properties.Name;
            xrlCredits.Text = "Số ĐVHT: " + infoSubject.Properties.TotalCredits;
            Catalogue_DepartmentInfo infodePartment = new Catalogue_DepartmentInfo(infoSubject.Properties.Catalogue_DepartmentKey.ToInt());
            xrlDepartment.Text = "KHOA: " + infodePartment.Properties.Name;
            Catalogue_SchoolYearInfo infoSchoolYear = new Catalogue_SchoolYearInfo(infoSubjectClass.Properties.Catalogue_SchoolYearKey.ToInt());
            xrlSchoolyear.Text = "NĂM HỌC: " + infoSchoolYear.Properties.Name;
            xrlSubjectClassID.Text = "MÃ LỚP HỌC PHẦN: " + infoSubjectClass.Properties.ID;
            Catalogue_TermInfo infoTerm = new Catalogue_TermInfo(infoSubjectClass.Properties.Catalogue_TermKey.ToInt());
            xrlTerm.Text = "BẢNG ĐIỂM HỌC PHẦN - HỌC KỲ: " + infoTerm.Properties.Name;
            if (infoSubjectClass.Properties.Training_ClassKey != null && infoSubjectClass.Properties.Training_ClassKey.ToString() != "")
            {
                Training_ClassInfo infoClass = new Training_ClassInfo(Convert.ToInt32(infoSubjectClass.Properties.Training_ClassKey));
                Catalogue_LevelInfo infoLevel = new Catalogue_LevelInfo(Convert.ToInt32(infoClass.Properties.Catalogue_LevelKey));
                Catalogue_MajorInfo infoMajor = new Catalogue_MajorInfo(Convert.ToInt32(infoClass.Properties.Catalogue_MajorKey));
                xrlLevel.Text = "HỆ: " + infoLevel.Properties.Name.ToUpper();
                xrlMajor.Text = "NGÀNH: " + infoMajor.Properties.Name.ToUpper();
            }
            if (infoSubjectClass.Properties.Personnel_PersonnelKey != null && infoSubjectClass.Properties.Personnel_PersonnelKey.ToString() != "")
            {
                Personnel_PersonnelInfo infoPersonel = new Personnel_PersonnelInfo(Guid.Parse(infoSubjectClass.Properties.Personnel_PersonnelKey.ToString()));
                xrlNamePersonel.Text ="Tên giảng viên: "+ infoPersonel.Properties.LastName + " " + infoPersonel.Properties.Name;
                Catalogue_DegreeInfo infoDegree = new Catalogue_DegreeInfo(Convert.ToInt32( infoPersonel.Properties.Catalogue_DegreeKey));
                xrlDegree.Text = "Học hàm - Học vị: " + infoDegree.Properties.Name;
            }
            #endregion
            #region [Bang diem]
            #region [Tittle]
            xrTableScore.BeginInit();
            xrTableCell1.Text = "";
            xrTableCell1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;
            #region [RowTitle 1]
            #region [Create new cell]
            XRTableRow rowTitle = new XRTableRow();
            XRTableCell cellSTT = new XRTableCell();
            XRTableCell cellMSSV = new XRTableCell();
            XRTableCell cellHoTen = new XRTableCell();
            XRTableCell cellGioiTinh = new XRTableCell();
            XRTableCell cellSinhNgay = new XRTableCell();
            XRTableCell cellKTTX = new XRTableCell();
            XRTableCell cellKTDK = new XRTableCell();
            XRTableCell cellDiemGiuaKi = new XRTableCell();
            XRTableCell cellKTCK = new XRTableCell();
            XRTableCell cellDiemHocPhan = new XRTableCell();
            XRTableCell cellGhiChu = new XRTableCell();
            #endregion
            cellSTT.Text = "STT";
            cellSTT.WidthF = 25;
            cellSTT.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellSTT.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellSTT.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left;

            cellMSSV.Text = "MSSV";
            cellMSSV.WidthF = 70;
            cellMSSV.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellMSSV.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellMSSV.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left;

            cellHoTen.Text = "HỌ VÀ TÊN";
            cellHoTen.WidthF = 170;
            cellHoTen.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellHoTen.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellHoTen.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left;

            cellGioiTinh.Text = " GIỚI ";
            cellGioiTinh.WidthF = 40;
            cellGioiTinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellGioiTinh.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellGioiTinh.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left;

            cellSinhNgay.Text = " NGÀY ";
            cellSinhNgay.WidthF = 60;
            cellSinhNgay.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellSinhNgay.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellSinhNgay.Borders = DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top;

            cellKTTX.Text = "KT THƯỜNG XUYÊN" + "\n(HS1)";
            cellKTTX.WidthF = 100;
            cellKTTX.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTTX.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTTX.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            cellKTDK.Text = "KT ĐỊNH KỲ     " + "\n(HS2)";
            cellKTDK.WidthF = 70;
            cellKTDK.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTDK.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTDK.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            cellDiemGiuaKi.Text = " ĐIỂM   \nGIỮA";
            cellDiemGiuaKi.WidthF = 40;
            cellDiemGiuaKi.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellDiemGiuaKi.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellDiemGiuaKi.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left;

            cellKTCK.Text = " KT CUỐI KỲ (50%) ";
            cellKTCK.WidthF = 150;
            cellKTCK.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTCK.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTCK.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            cellDiemHocPhan.Text = "ĐIỂM HỌC PHẦN";
            cellDiemHocPhan.WidthF = 120;
            cellDiemHocPhan.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellDiemHocPhan.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellDiemHocPhan.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            cellGhiChu.Text = "GHI";
            cellGhiChu.WidthF = 40;
            cellGhiChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
            cellGhiChu.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellGhiChu.Borders = DevExpress.XtraPrinting.BorderSide.Top | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            #region [Row add cell]
            rowTitle.Controls.Add(cellSTT);
            rowTitle.Controls.Add(cellMSSV);
            rowTitle.Controls.Add(cellHoTen);
            rowTitle.Controls.Add(cellGioiTinh);
            rowTitle.Controls.Add(cellSinhNgay);
            rowTitle.Controls.Add(cellKTTX);
            rowTitle.Controls.Add(cellKTDK);
            rowTitle.Controls.Add(cellDiemGiuaKi);
            rowTitle.Controls.Add(cellKTCK);
            rowTitle.Controls.Add(cellDiemHocPhan);
            rowTitle.Controls.Add(cellGhiChu);
            xrTableScore.Controls.Add(rowTitle);
            #endregion 
            #endregion
            #region [RowTitle 2]

            #region [Create new cell]
            XRTableRow rowTitle1 = new XRTableRow();
            XRTableCell cellSTT1 = new XRTableCell();
            XRTableCell cellMSSV1 = new XRTableCell();
            XRTableCell cellHoTen1 = new XRTableCell();
            XRTableCell cellGioiTinh1 = new XRTableCell();
            XRTableCell cellSinhNgay1 = new XRTableCell();
            XRTableCell cellKTTX_Bai1 = new XRTableCell();
            XRTableCell cellKTTX_Bai2 = new XRTableCell();
            XRTableCell cellKTDK_Bai1 = new XRTableCell();
            XRTableCell cellKTDK_Bai2 = new XRTableCell();
            XRTableCell cellDiemGiuaKi1 = new XRTableCell();
            XRTableCell cellKTCK_DiemSo = new XRTableCell();
            XRTableCell cellKTCK_DiemChu = new XRTableCell();
            XRTableCell cellKTCK_ChuKy = new XRTableCell();
            XRTableCell cellKTCK_SoTo = new XRTableCell();
            XRTableCell cellDiemHocPhan_DiemSo = new XRTableCell();
            XRTableCell cellDiemHocPhan_DiemChu = new XRTableCell();
            XRTableCell cellGhiChu1 = new XRTableCell();
            #endregion
            cellSTT1.Text = "";
            cellSTT1.WidthF = 25;
            cellSTT1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellMSSV1.Text = "";
            cellMSSV1.WidthF = 70;
            cellMSSV1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellHoTen1.Text = "";
            cellHoTen1.WidthF = 170;
            cellHoTen1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellGioiTinh1.Text = "  TÍNH ";
            cellGioiTinh1.WidthF = 40;
            cellGioiTinh1.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellGioiTinh1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
            cellGioiTinh1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellSinhNgay1.Text = " SINH ";
            cellSinhNgay1.WidthF = 60;
            cellSinhNgay1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
            cellSinhNgay1.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
            cellSinhNgay1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellDiemGiuaKi1.Text = "   KỲ   " + "  \n(50%)  ";
            cellDiemGiuaKi1.WidthF = 40;
            cellDiemGiuaKi1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
            cellDiemGiuaKi1.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellDiemGiuaKi1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left;

            cellGhiChu1.Text = "CHÚ";
            cellGhiChu1.WidthF = 40;
            cellGhiChu1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
            cellGhiChu1.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellGhiChu1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom | DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right;

            cellKTTX_Bai1.Text = "BÀI 1";
            cellKTTX_Bai1.WidthF = 50;
            cellKTTX_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTTX_Bai1.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTTX_Bai1.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTTX_Bai2.Text = "BÀI 2";
            cellKTTX_Bai2.WidthF = 50;
            cellKTTX_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTTX_Bai2.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTTX_Bai2.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTDK_Bai1.Text = "BÀI 1";
            cellKTDK_Bai1.WidthF =35;
            cellKTDK_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTDK_Bai1.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTDK_Bai1.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTDK_Bai2.Text = "BÀI 2";
            cellKTDK_Bai2.WidthF =35;
            cellKTDK_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTDK_Bai2.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTDK_Bai2.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTCK_DiemSo.Text = "ĐIỂM SỐ";
            cellKTCK_DiemSo.WidthF = 35;
            cellKTCK_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTCK_DiemSo.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTCK_DiemSo.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTCK_DiemChu.Text = "ĐIỂM CHỮ";
            cellKTCK_DiemChu.WidthF = 45;
            cellKTCK_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTCK_DiemChu.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTCK_DiemChu.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTCK_ChuKy.Text = "CHỮ KÝ";
            cellKTCK_ChuKy.WidthF = 40;
            cellKTCK_ChuKy.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTCK_ChuKy.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTCK_ChuKy.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellKTCK_SoTo.Text = "SỐ TỜ";
            cellKTCK_SoTo.WidthF = 30;
            cellKTCK_SoTo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellKTCK_SoTo.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellKTCK_SoTo.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellDiemHocPhan_DiemChu.Text = "ĐIỂM CHỮ";
            cellDiemHocPhan_DiemChu.WidthF = 80;
            cellDiemHocPhan_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellDiemHocPhan_DiemChu.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellDiemHocPhan_DiemChu.Borders = DevExpress.XtraPrinting.BorderSide.All;

            cellDiemHocPhan_DiemSo.Text = "ĐIỂM SỐ";
            cellDiemHocPhan_DiemSo.WidthF = 40;
            cellDiemHocPhan_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cellDiemHocPhan_DiemSo.Font = new System.Drawing.Font(this.Font.Name, 8, FontStyle.Bold);
            cellDiemHocPhan_DiemSo.Borders = DevExpress.XtraPrinting.BorderSide.All;

            #region [row add cell]
            rowTitle1.Controls.Add(cellSTT1);
            rowTitle1.Controls.Add(cellMSSV1);
            rowTitle1.Controls.Add(cellHoTen1);
            rowTitle1.Controls.Add(cellGioiTinh1);
            rowTitle1.Controls.Add(cellSinhNgay1);
            rowTitle1.Controls.Add(cellKTTX_Bai1);
            rowTitle1.Controls.Add(cellKTTX_Bai2);
            rowTitle1.Controls.Add(cellKTDK_Bai1);
            rowTitle1.Controls.Add(cellKTDK_Bai2);
            rowTitle1.Controls.Add(cellDiemGiuaKi1);
            rowTitle1.Controls.Add(cellKTCK_DiemSo);
            rowTitle1.Controls.Add(cellKTCK_DiemChu);
            rowTitle1.Controls.Add(cellKTCK_ChuKy);
            rowTitle1.Controls.Add(cellKTCK_SoTo);
            rowTitle1.Controls.Add(cellDiemHocPhan_DiemSo);
            rowTitle1.Controls.Add(cellDiemHocPhan_DiemChu);
            rowTitle1.Controls.Add(cellGhiChu1);
            xrTableScore.Controls.Add(rowTitle1);
            #endregion
            #endregion
            #endregion
            #region [Contents]
            #region [Info]
            DataTable _dtStudentInfo = new DataTable();
            _dtStudentInfo = m_Score.m_DCReadOnly.Training_Student_Subject_Classes.GetStudentsSubjectClass(
                                                   m_Score.m_DCReadOnly.Training_Student_Classes,
                                                   m_Score.m_DCReadOnly.Training_Students, m_iSubjectClassKey).ToDataTable();
            DataTable _dtScoreList = new DataTable();
            _dtScoreList = m_Score.m_DCReadOnly.Training_Scores.getScores(m_iSubjectClassKey).ToDataTable();
            #endregion
            if (_dtStudentInfo.Rows.Count > 0)
            {
                #region [Lop da nhap diem]
                if (_dtScoreList.Rows.Count > 0)//Lop da nhap diem
                {
                    #region [Add score into _dtStudentInfo]
                    _dtStudentInfo.Columns.Add("KTTX1");
                    _dtStudentInfo.Columns.Add("KTTX2");
                    _dtStudentInfo.Columns.Add("KTDK1");
                    _dtStudentInfo.Columns.Add("KTDK2");
                    _dtStudentInfo.Columns.Add("GiuaKy");
                    _dtStudentInfo.Columns.Add("CuoiKy");
                    _dtStudentInfo.Columns.Add("HocPhan");
                    _dtStudentInfo.Columns.Add("GhiChu");
                    for (int i = 0; i < _dtStudentInfo.Rows.Count; i++)
                    {
                        for (int j = 0; j < m_lScoreType.Count; j++)
                        {
                            #region [Filter Score By ScoreType]
                            DataTable _dtScoreListByScoreType = new DataTable();
                            DataRow[] _drScoreListByScoreType = _dtScoreList.Select("[Training_ScoreTypeKey]='" + m_lScoreType[j].ToString() + "'");
                            _dtScoreListByScoreType = _dtScoreList.Clone();
                            foreach (DataRow dr in _drScoreListByScoreType)
                            {
                                _dtScoreListByScoreType.ImportRow(dr);
                            }
                            #endregion
                            if (m_lScoreType.Count <= 3)
                            {
                                #region [Mon hoc 3 DVHT]
                                if (_dtScoreListByScoreType.Rows.Count > 0)//Add diem kiem tra thuong xuyen 1
                                {
                                    if (j == 0)
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTTX1"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == 1)//Add cot diem kiem tra dinh ki va tinh diem giua ki
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTDK1"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                double _dGK = 0;
                                                if (_dtStudentInfo.Rows[i]["KTTX1"] != null && _dtStudentInfo.Rows[i]["KTTX1"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTTX1"].ToString());
                                                }
                                                if (_dtStudentInfo.Rows[i]["KTDK1"] != null && _dtStudentInfo.Rows[i]["KTDK1"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTDK1"].ToString()) * 2;
                                                }
                                                _dtStudentInfo.Rows[i]["GiuaKy"] = Math.Round(_dGK / 3, 0, MidpointRounding.AwayFromZero);
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == m_lScoreType.Count - 1)//Add cot diem thi 
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["CuoiKy"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                double _dHP = 0;
                                                if (_dtStudentInfo.Rows[i]["GiuaKy"] != null && _dtStudentInfo.Rows[i]["GiuaKy"].ToString() != "")
                                                {
                                                    _dHP += Convert.ToDouble(_dtStudentInfo.Rows[i]["GiuaKy"].ToString());
                                                }
                                                if (_dtStudentInfo.Rows[i]["CuoiKy"] != null && _dtStudentInfo.Rows[i]["CuoiKy"].ToString() != "")
                                                {
                                                    _dHP += Convert.ToDouble(_dtStudentInfo.Rows[i]["CuoiKy"].ToString());
                                                }
                                                _dtStudentInfo.Rows[i]["HocPhan"] = Math.Round(_dHP / 2, 1, MidpointRounding.AwayFromZero);
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                }
                                #endregion
                            }
                            else
                            {
                                #region [Mon hoc 4 DVHT]
                                if (_dtScoreListByScoreType.Rows.Count > 0)//Add diem kiem tra thuong xuyen 1
                                {
                                    if (j == 0)
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTTX1"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == 1)
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTTX2"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == 2)
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTDK1"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == 3)//Add cot diem kiem tra dinh ki va tinh diem giua ki
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["KTDK2"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                double _dGK = 0;
                                                if (_dtStudentInfo.Rows[i]["KTTX1"] != null && _dtStudentInfo.Rows[i]["KTTX1"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTTX1"].ToString());
                                                }
                                                if (_dtStudentInfo.Rows[i]["KTTX2"] != null && _dtStudentInfo.Rows[i]["KTTX2"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTTX2"].ToString());
                                                }
                                                if (_dtStudentInfo.Rows[i]["KTDK1"] != null && _dtStudentInfo.Rows[i]["KTDK1"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTDK1"].ToString()) * 2;
                                                }
                                                if (_dtStudentInfo.Rows[i]["KTDK2"] != null && _dtStudentInfo.Rows[i]["KTDK2"].ToString() != "")
                                                {
                                                    _dGK += Convert.ToDouble(_dtStudentInfo.Rows[i]["KTDK2"].ToString()) * 2;
                                                }
                                                _dtStudentInfo.Rows[i]["GiuaKy"] = Math.Round(_dGK / 6, 0, MidpointRounding.AwayFromZero);
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                    if (j == m_lScoreType.Count - 1)//Add cot diem thi 
                                    {
                                        for (int l = 0; l < _dtScoreListByScoreType.Rows.Count; l++)
                                        {
                                            if (_dtStudentInfo.Rows[i]["Training_StudentKey"].ToString() == _dtScoreListByScoreType.Rows[l]["Training_StudentKey"].ToString())
                                            {
                                                _dtStudentInfo.Rows[i]["CuoiKy"] = _dtScoreListByScoreType.Rows[l]["Score"].ToString();
                                                double _dHP = 0;
                                                if (_dtStudentInfo.Rows[i]["GiuaKy"] != null && _dtStudentInfo.Rows[i]["GiuaKy"].ToString() != "")
                                                {
                                                    _dHP += Convert.ToDouble(_dtStudentInfo.Rows[i]["GiuaKy"].ToString());
                                                }
                                                if (_dtStudentInfo.Rows[i]["CuoiKy"] != null && _dtStudentInfo.Rows[i]["CuoiKy"].ToString() != "")
                                                {
                                                    _dHP += Convert.ToDouble(_dtStudentInfo.Rows[i]["CuoiKy"].ToString());
                                                }
                                                _dtStudentInfo.Rows[i]["HocPhan"] = Math.Round(_dHP / 2, 1, MidpointRounding.AwayFromZero);
                                                _dtStudentInfo.Rows[i]["GhiChu"] = _dtScoreListByScoreType.Rows[l]["Note"].ToString();
                                                _dtScoreListByScoreType.Rows[l].Delete();
                                                break;
                                            }
                                        }
                                    }
                                }
                                #endregion
                            }
                        }
                    #endregion
                        //Xuat thong tin
                        #region [Create new cell content]
                        XRTableRow rowContent = new XRTableRow();
                        XRTableCell cellContentSTT = new XRTableCell();
                        XRTableCell cellContentMSSV = new XRTableCell();
                        XRTableCell cellContentHoSV = new XRTableCell();
                        XRTableCell cellContentTenSV = new XRTableCell();
                        XRTableCell cellContentGioiTinh = new XRTableCell();
                        XRTableCell cellContentNgaySinh = new XRTableCell();
                        XRTableCell cellContentKTTX_Bai1 = new XRTableCell();
                        XRTableCell cellContentKTTX_Bai2 = new XRTableCell();
                        XRTableCell cellContentKTDK_Bai1 = new XRTableCell();
                        XRTableCell cellContentKTDK_Bai2 = new XRTableCell();
                        XRTableCell cellContentDiemGiuaKi = new XRTableCell();
                        XRTableCell cellContentKTCK_DiemSo = new XRTableCell();
                        XRTableCell cellContentKTCK_DiemChu = new XRTableCell();
                        XRTableCell cellContentKTCK_ChuKy = new XRTableCell();
                        XRTableCell cellContentKTCK_SoTo = new XRTableCell();
                        XRTableCell cellContentDiemHocPhan_DiemSo = new XRTableCell();
                        XRTableCell cellContentDiemHocPhan_DiemChu = new XRTableCell();
                        XRTableCell cellContentGhiChu = new XRTableCell();
                        #endregion
                        #region [Detail StudentInfo]

                        cellContentSTT.Text =  (i + 1).ToString();
                        cellContentSTT.WidthF = 25;
                        cellContentSTT.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        

                        cellContentMSSV.Text = _dtStudentInfo.Rows[i]["ID"].ToString();
                        cellContentMSSV.WidthF = 70;
                        cellContentMSSV.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentHoSV.Text = " "+_dtStudentInfo.Rows[i]["LastName"].ToString();
                        cellContentHoSV.WidthF = 120;

                        cellContentTenSV.Text = " "+_dtStudentInfo.Rows[i]["SureName"].ToString();
                        cellContentTenSV.WidthF = 50;

                        cellContentGioiTinh.Text = _dtStudentInfo.Rows[i]["Gender"].ToString();
                        cellContentGioiTinh.WidthF = 40;
                        cellContentGioiTinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        DateTime date;
                        if (DateTime.TryParse(_dtStudentInfo.Rows[i]["Birthday"].ToString(), out date))
                        {
                            cellContentNgaySinh.Text = date.ToString("dd/MM/yyyy");
                            cellContentNgaySinh.WidthF = 60;
                            cellContentNgaySinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        else
                        {
                            cellContentNgaySinh.Text = _dtStudentInfo.Rows[i]["Birthday"].ToString();
                            cellContentNgaySinh.WidthF = 60;
                            cellContentNgaySinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        #endregion
                        #region [Detail Score]
                        cellContentKTTX_Bai1.Text = _dtStudentInfo.Rows[i]["KTTX1"].ToString();
                        cellContentKTTX_Bai1.WidthF = 50;
                        cellContentKTTX_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTTX_Bai2.Text = _dtStudentInfo.Rows[i]["KTTX2"].ToString();
                        cellContentKTTX_Bai2.WidthF = 50;
                        cellContentKTTX_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTDK_Bai1.Text = _dtStudentInfo.Rows[i]["KTDK1"].ToString();
                        cellContentKTDK_Bai1.WidthF = 35;
                        cellContentKTDK_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTDK_Bai2.Text = _dtStudentInfo.Rows[i]["KTDK2"].ToString();
                        cellContentKTDK_Bai2.WidthF = 35;
                        cellContentKTDK_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentDiemGiuaKi.Text = _dtStudentInfo.Rows[i]["GiuaKy"].ToString();
                        cellContentDiemGiuaKi.WidthF = 40;
                        cellContentDiemGiuaKi.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentDiemGiuaKi.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_DiemSo.Text = _dtStudentInfo.Rows[i]["CuoiKy"].ToString();
                        cellContentKTCK_DiemSo.WidthF = 35;
                        cellContentKTCK_DiemSo.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentKTCK_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        if (_dtStudentInfo.Rows[i]["CuoiKy"] != null && _dtStudentInfo.Rows[i]["CuoiKy"].ToString() != "")
                        {
                            cellContentKTCK_DiemChu.Text = UppercaseFirst(m_readnumber.Convert(_dtStudentInfo.Rows[i]["CuoiKy"].ToString(), '.', "chấm"));
                            cellContentKTCK_DiemChu.WidthF = 45;
                            cellContentKTCK_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        else
                        {
                            cellContentKTCK_DiemChu.Text = "";
                            cellContentKTCK_DiemChu.WidthF = 45;
                            cellContentKTCK_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }

                        cellContentKTCK_ChuKy.Text = "";
                        cellContentKTCK_ChuKy.WidthF = 40;
                        cellContentKTCK_ChuKy.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_SoTo.Text = "";
                        cellContentKTCK_SoTo.WidthF = 30;
                        cellContentKTCK_SoTo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentDiemHocPhan_DiemSo.Text = _dtStudentInfo.Rows[i]["HocPhan"].ToString();
                        cellContentDiemHocPhan_DiemSo.WidthF = 40;
                        cellContentDiemHocPhan_DiemSo.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentDiemHocPhan_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        if (_dtStudentInfo.Rows[i]["HocPhan"] != null && _dtStudentInfo.Rows[i]["HocPhan"].ToString() != "")
                        {
                            cellContentDiemHocPhan_DiemChu.Text = UppercaseFirst(m_readnumber.Convert(_dtStudentInfo.Rows[i]["HocPhan"].ToString(), '.', "chấm"));
                            cellContentDiemHocPhan_DiemChu.WidthF = 80;
                            cellContentDiemHocPhan_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        else
                        {
                            cellContentDiemHocPhan_DiemChu.Text = "";
                            cellContentDiemHocPhan_DiemChu.WidthF = 80;
                            cellContentDiemHocPhan_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }

                        cellContentGhiChu.Text = _dtStudentInfo.Rows[i]["GhiChu"].ToString();
                        cellContentGhiChu.WidthF = 40;
                        cellContentGhiChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
                        #endregion
                        #region [Add new row]
                        rowContent.Controls.Add(cellContentSTT);
                        rowContent.Controls.Add(cellContentMSSV);
                        rowContent.Controls.Add(cellContentHoSV);
                        rowContent.Controls.Add(cellContentTenSV);
                        rowContent.Controls.Add(cellContentGioiTinh);
                        rowContent.Controls.Add(cellContentNgaySinh);
                        rowContent.Controls.Add(cellContentKTTX_Bai1);
                        rowContent.Controls.Add(cellContentKTTX_Bai2);
                        rowContent.Controls.Add(cellContentKTDK_Bai1);
                        rowContent.Controls.Add(cellContentKTDK_Bai2);
                        rowContent.Controls.Add(cellContentDiemGiuaKi);
                        rowContent.Controls.Add(cellContentKTCK_DiemSo);
                        rowContent.Controls.Add(cellContentKTCK_DiemChu);
                        rowContent.Controls.Add(cellContentKTCK_ChuKy);
                        rowContent.Controls.Add(cellContentKTCK_SoTo);
                        rowContent.Controls.Add(cellContentDiemHocPhan_DiemSo);
                        rowContent.Controls.Add(cellContentDiemHocPhan_DiemChu);
                        rowContent.Controls.Add(cellContentGhiChu);

                        rowContent.Borders = DevExpress.XtraPrinting.BorderSide.All;
                        xrTableScore.Controls.Add(rowContent);
                        #endregion
                    }
                }
                #endregion
                #region [Lop chua nhap diem]
                else//Lop chua nhap diem
                {
                    #region
                    for (int i = 0; i < _dtStudentInfo.Rows.Count; i++)
                    {
                        #region [Create new cell content]
                        XRTableRow rowContent = new XRTableRow();
                        XRTableCell cellContentSTT = new XRTableCell();
                        XRTableCell cellContentMSSV = new XRTableCell();
                        XRTableCell cellContentHoSV = new XRTableCell();
                        XRTableCell cellContentTenSV = new XRTableCell();
                        XRTableCell cellContentGioiTinh = new XRTableCell();
                        XRTableCell cellContentNgaySinh = new XRTableCell();
                        XRTableCell cellContentKTTX_Bai1 = new XRTableCell();
                        XRTableCell cellContentKTTX_Bai2 = new XRTableCell();
                        XRTableCell cellContentKTDK_Bai1 = new XRTableCell();
                        XRTableCell cellContentKTDK_Bai2 = new XRTableCell();
                        XRTableCell cellContentDiemGiuaKi = new XRTableCell();
                        XRTableCell cellContentKTCK_DiemSo = new XRTableCell();
                        XRTableCell cellContentKTCK_DiemChu = new XRTableCell();
                        XRTableCell cellContentKTCK_ChuKy = new XRTableCell();
                        XRTableCell cellContentKTCK_SoTo = new XRTableCell();
                        XRTableCell cellContentDiemHocPhan_DiemSo = new XRTableCell();
                        XRTableCell cellContentDiemHocPhan_DiemChu = new XRTableCell();
                        XRTableCell cellContentGhiChu = new XRTableCell();
                        #endregion
                        #region [Detail]

                        cellContentSTT.Text = (i + 1).ToString();
                        cellContentSTT.WidthF = 25;
                        cellContentSTT.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentMSSV.Text = _dtStudentInfo.Rows[i]["ID"].ToString();
                        cellContentMSSV.WidthF = 70;
                        cellContentMSSV.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentHoSV.Text = " "+_dtStudentInfo.Rows[i]["LastName"].ToString();
                        cellContentHoSV.WidthF = 120;

                        cellContentTenSV.Text = " "+_dtStudentInfo.Rows[i]["SureName"].ToString();
                        cellContentTenSV.WidthF = 50;

                        cellContentGioiTinh.Text = _dtStudentInfo.Rows[i]["Gender"].ToString();
                        cellContentGioiTinh.WidthF = 40;
                        cellContentGioiTinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        DateTime date;
                        if (DateTime.TryParse(_dtStudentInfo.Rows[i]["Birthday"].ToString(), out date))
                        {
                            cellContentNgaySinh.Text = date.ToString("dd/MM/yyyy");
                            cellContentNgaySinh.WidthF = 60;
                            cellContentNgaySinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        else
                        {
                            cellContentNgaySinh.Text = _dtStudentInfo.Rows[i]["Birthday"].ToString();
                            cellContentNgaySinh.WidthF = 60;
                            cellContentNgaySinh.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                        }
                        cellContentKTTX_Bai1.Text = "";
                        cellContentKTTX_Bai1.WidthF = 50;
                        cellContentKTTX_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTTX_Bai2.Text = "";
                        cellContentKTTX_Bai2.WidthF = 50;
                        cellContentKTTX_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTDK_Bai1.Text = "";
                        cellContentKTDK_Bai1.WidthF = 35;
                        cellContentKTDK_Bai1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTDK_Bai2.Text = "";
                        cellContentKTDK_Bai2.WidthF = 35;
                        cellContentKTDK_Bai2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentDiemGiuaKi.Text = "";
                        cellContentDiemGiuaKi.WidthF = 40;
                        cellContentDiemGiuaKi.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentDiemGiuaKi.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_DiemSo.Text = "";
                        cellContentKTCK_DiemSo.WidthF = 35;
                        cellContentKTCK_DiemSo.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentKTCK_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_DiemChu.Text = "";
                        cellContentKTCK_DiemChu.WidthF = 45;
                        cellContentKTCK_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_ChuKy.Text = "";
                        cellContentKTCK_ChuKy.WidthF = 40;
                        cellContentKTCK_ChuKy.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentKTCK_SoTo.Text = "";
                        cellContentKTCK_SoTo.WidthF = 30;
                        cellContentKTCK_SoTo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentDiemHocPhan_DiemSo.Text = "";
                        cellContentDiemHocPhan_DiemSo.WidthF = 40;
                        cellContentDiemHocPhan_DiemSo.Font = new System.Drawing.Font(this.Font, FontStyle.Bold);
                        cellContentDiemHocPhan_DiemSo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentDiemHocPhan_DiemChu.Text = "";
                        cellContentDiemHocPhan_DiemChu.WidthF = 80;
                        cellContentDiemHocPhan_DiemChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

                        cellContentGhiChu.Text = "";
                        cellContentGhiChu.WidthF = 40;
                        cellContentGhiChu.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
                        #endregion
                        #region [Add new row]
                        rowContent.Controls.Add(cellContentSTT);
                        rowContent.Controls.Add(cellContentMSSV);
                        rowContent.Controls.Add(cellContentHoSV);
                        rowContent.Controls.Add(cellContentTenSV);
                        rowContent.Controls.Add(cellContentGioiTinh);
                        rowContent.Controls.Add(cellContentNgaySinh);
                        rowContent.Controls.Add(cellContentKTTX_Bai1);
                        rowContent.Controls.Add(cellContentKTTX_Bai2);
                        rowContent.Controls.Add(cellContentKTDK_Bai1);
                        rowContent.Controls.Add(cellContentKTDK_Bai2);
                        rowContent.Controls.Add(cellContentDiemGiuaKi);
                        rowContent.Controls.Add(cellContentKTCK_DiemSo);
                        rowContent.Controls.Add(cellContentKTCK_DiemChu);
                        rowContent.Controls.Add(cellContentKTCK_ChuKy);
                        rowContent.Controls.Add(cellContentKTCK_SoTo);
                        rowContent.Controls.Add(cellContentDiemHocPhan_DiemSo);
                        rowContent.Controls.Add(cellContentDiemHocPhan_DiemChu);
                        rowContent.Controls.Add(cellContentGhiChu);

                        rowContent.Borders = DevExpress.XtraPrinting.BorderSide.All;
                        xrTableScore.Controls.Add(rowContent);
                        #endregion
                    }
                    #endregion
                }
                #endregion
            }
            xrTableScore.EndInit();
            #endregion
            #endregion
        }
        /// <summary>
        /// In hoa chu cai dau tien
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        private string UppercaseFirst(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            char[] a = s.ToCharArray();
            a[0] = char.ToUpper(a[0]);
            return new string(a);
        }
    }

}
